import { View } from "../../../../mvc/core/View";
import { LayerManager } from "../../../manager/LayerManager";
import { ConfigManager } from "../../../../../com/gengine/resource/ConfigManager";
import { GSprite } from "../../../../../com/mui/controls/GSprite";
import { ObjCreate } from "../../common/ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { SkillComposeTipsRenderer } from "./SkillComposeTipsRenderer";
import { ScrollPolicy } from "../../../../../fl/controls/ScrollPolicy";
import { SoundManager } from "../../../../common/sound/SoundManager";
import { SoundTypeConst } from "../../../../common/sound/SoundTypeConst";
import { Global } from "../../../../../com/gengine/global/Global";
import { SkillInfo } from "../../../model/SkillInfo";
import { SkillConfig } from "../../../resource/SkillConfig";
import { DataProvider } from "../../../../../fl/data/DataProvider";
import { GTileList } from "../../../../../com/mui/controls/GTileList";
import { GButton } from "../../../../../com/mui/controls/GButton";
//class SkillComposeTipsView
    
    export  class SkillComposeTipsView extends View
    {
        constructor()
        {
            super();
            this.initUI();
            layer = LayerManager.windowLayer;
            return;
        }

        /* internal  */initUI(): void
        {
            this._obj = ConfigManager.instance.getJSONByFileName("t_chaos_fight_formula.json");
            this._sp = new GSprite();
            addChild(this._sp);
            this._sp.addEventListener(flash.events.MouseEvent.MOUSE_DOWN, this.onMoveMouseDown);
            var loc1=ObjCreate.createBg(0, 0, 335, 445, this, ImagesConst.ToolTipBg);
            this._sp.addChildAt(loc1, 0);
            this._list = ObjCreate.createTileList(10, 10, 325, 430, this);
            this._list.columnWidth = 308;
            this._list.rowHeight = 115;
            this._list.setStyle("cellRenderer", SkillComposeTipsRenderer);
            this._list.horizontalScrollPolicy = ScrollPolicy.OFF;
            this._list.verticalScrollPolicy = ScrollPolicy.OFF;
            this._closeBtn = ObjCreate.createGButton("", 295, 8, 19, 19, this._sp, "CloseButton");
            this._closeBtn.focusEnabled = true;
            this._closeBtn.name = "Window_Btn_Close";
            this._closeBtn.configEventListener(flash.events.MouseEvent.CLICK, this.closeBtnClickHandler);
            return;
        }

        protected closeBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            SoundManager.instance.soundPlay(SoundTypeConst.UIclose);
            hide();
            return;
        }

        /* internal  */onMoveMouseDown(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (arg1.currentTarget == this._sp || arg1.target == this._sp) 
            {
                this.startDrag();
                Global.stage.addEventListener(flash.events.MouseEvent.MOUSE_UP, this.onStageMouseUpHandler);
            }
            return;
        }

        /* internal  */onStageMouseUpHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.stopDrag();
            Global.stage.removeEventListener(flash.events.MouseEvent.MOUSE_UP, this.onStageMouseUpHandler);
            return;
        }

        public updateSkill(): void
        {
            var loc1=null;
            var loc2=0;
            var loc3=this._obj;
            for(loc1 of loc3) 
            {
                if (!loc1.skillId) 
                {
                    continue;
                }
                this._skillInfo = new SkillInfo();
                this._skillInfo.tSkill = SkillConfig.instance.getInfoByName(loc1.skillId);
                loc1.skillInfo = this._skillInfo;
            }
            this._list.dataProvider = new DataProvider(this._obj);
            this._list.drawNow();
            return;
        }

        /* internal */ /* var */_sp: GSprite;

        /* internal */ /* var */_list: GTileList;

        /* internal */ /* var */_closeBtn: GButton;

        /* internal */ /* var */_obj: Object;

        /* internal */ /* var */_skillInfo: SkillInfo;
    }
